package com.sjzpalh.dss.push.client;

import com.sjzpalh.dss.push.primitive.ChatMessageCmd;
import com.sjzpalh.dss.push.primitive.ExitRequest;
import com.sjzpalh.dss.push.primitive.LoginRequest;
import com.sjzpalh.dss.push.primitive.LogoutRequest;
import com.sjzpalh.dss.push.primitive.MessageInfo;
import com.sjzpalh.dss.push.primitive.Ping;
import com.sjzpalh.dss.push.primitive.UserName;
import com.sjzpalh.dss.push.util.DefaultIdGenerator;
import com.sjzpalh.dss.push.util.IdGenerator;

/**
 * Simple client with pre-recorded commands to login the Alice user before using the text UI.
 * @author
 */
public class ClientAlice {
	
	public static Client client;
    public static void main(String[] aArgs) throws InterruptedException {
		IdGenerator idGen = DefaultIdGenerator.getInstance();
		RecordedCommandReader cmdReader1 = new RecordedCommandReader();
		cmdReader1.add(new LoginRequest(idGen.nextId(), new UserName("Alice"),
				"mypass"));		
		//cmdReader1.add(new Ping(idGen.nextId()));
		ConsoleReader reader2 = new ConsoleReader(idGen);
		RecordedCommandReader reader3 = new RecordedCommandReader();
		reader3.add(new LogoutRequest(idGen.nextId())).add(
				new ExitRequest(idGen.nextId()));
		client = new Client(new CompositeReader(cmdReader1, reader2,
				reader3));
		client.start();	
//		UserName uname=new UserName("Alice");
//		
//		while(true)
//		{
//			ChatMessageCmd msg = new ChatMessageCmd(idGen.nextId(), 
//	                new MessageInfo(uname, uname,"5555555555"));
//
//			client.ExecCmdThread(msg);
//			Thread.sleep(3000);
//
//		}
//		
		
    }
}
